Skip to content

Fix all ofs with nullable properties in OpenAPI 3.1 specs - #25064

Merged
wing328 merged 3 commits into
OpenAPITools:masterfrom
JulianVennen:all-of-nullable
Oct 5, 2026
Merged

wing328 merged 3 commits into
OpenAPITools:masterfrom
JulianVennen:all-of-nullable

Conversation

@JulianVennen

@JulianVennen JulianVennen commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes an error where using all ofs with nullable properties in an OpenAPI spec causes the nullability to get lost.
For an example spec see modules/openapi-generator/src/test/resources/3_1/allof-nullable-type-array.yaml

In this example, id should be nullable in both Base and Derived, but in the generated code (e.g. using the php-nextgen) generator, it is only nullable for Base. That happens because the normalizer turns the 3.1 spec's types: ['string', 'null'] into type: string and nullable: true, but AnnotationsUtils.clone parses the spec as 3.1 where that property doesn't exist and therefore skips it.

This should fix the following issues as well:

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes nullability being lost on properties merged into models via allOf in OpenAPI 3.1 specs.

cloneSchema now restores the nullable flag on the clone and at every nested level (properties, array items, additionalProperties, not, and composed sub-schemas), since the OAS 3.1 serializer drops it. The normalizer rewrites type: [<type>, "null"] into nullable: true, so the flag must survive cloning. Resolves related generator issues for python-flask, typescript-axios, and csharp.

Written for commit c7a1933. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@wing328 wing328 added this to the 7.26.0 milestone Oct 5, 2026
@wing328
wing328 merged commit e0f8a28 into OpenAPITools:master Oct 5, 2026
15 checks passed
@wing328

wing328 commented Oct 5, 2026

Copy link
Copy Markdown
Member

lgtm. thanks for the fix

ondrej-simon added a commit to ondrej-simon/openapi-generator that referenced this pull request Oct 6, 2026
The sample on master is out of date after OpenAPITools#25064 and OpenAPITools#25089 were merged
concurrently, which fails the "Samples up-to-date" check.
@JulianVennen
JulianVennen deleted the all-of-nullable branch October 6, 2026 12:58
wing328 pushed a commit that referenced this pull request Oct 7, 2026
…#25138)

* [Java][webclient/restclient/resttemplate] Simplify generated API code

- Only null-check optional header, cookie and form parameters (and use
  braces); required parameters are already validated to be non-null
- Pass the request body to invokeAPI directly instead of through a
  redundant postBody local variable
- Use the diamond operator for generic instantiations; for anonymous
  ParameterizedTypeReference classes only when targeting Java 17
- Set the java17 flag for resttemplate when using Jakarta EE and use it
  to select the Java version in its pom.xml and build.gradle (which also
  removes duplicated source/target elements with Spring Boot 4)

* Update stale go-oneof-not-enum sample

The sample on master is out of date after #25064 and #25089 were merged
concurrently, which fails the "Samples up-to-date" check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants